<?php

function extraire_marque($id) {

    if (file_exists('Fichiers/Description_auto.xml')) {
        $xml_description_auto = simplexml_load_file('Fichiers/Description_auto.xml');
        $_SESSION['xml_description_auto'] = $xml_description_auto;
    } else {
        exit('Echec lors de l\'ouverture du fichier xml.');
    }
    $w = 0;
    for ($i = 0; $i < count($xml_description_auto->ROW); $i++) {
            if (str_replace(" ", "", $xml_description_auto->ROW[$i]->marque) == str_replace(" ", "", $xml_description_auto->ROW[intval($id)]->marque)) {
                $w = 0;
                $res[$w] =  $xml_description_auto->ROW[$i];
                $w++;
            }
    }
    return $res;
}


function extraire_modele($id) {

    if (file_exists('Fichiers/Description_auto.xml')) {
        $xml_description_auto = simplexml_load_file('Fichiers/Description_auto.xml');
        $_SESSION['xml_description_auto'] = $xml_description_auto;
    } else {
        exit('Echec lors de l\'ouverture du fichier xml.');
    }
    $w = 0;
    for ($i = 0; $i < count($xml_description_auto->ROW); $i++) {
            if (str_replace(" ", "", $xml_description_auto->ROW[$i]->modele) == str_replace(" ", "", $xml_description_auto->ROW[intval($id)]->modele)) {
                $w = 0;
                $res[$w] =  $xml_description_auto->ROW[$i];
                $w++;
            }
    }
    return $res;
}
?>
